const  baseURL = 'http://101.37.76.80:8848/';

const request =(method, url, data) => new Promise((resolve, reject) => {
  const token = wx.getStorageSync('token')
  wx.request({
    url: `${baseURL}${url}`,
    complete: (res) => {},
    data: data,
    dataType: 'json',
    fail: (res) => {},
    header: {'content-type': 'application/json', "Authorization": token},
    method: method,
    responseType: 'text',
    success: (res) => {
      resolve(res)
    },
    fail: (res)=>{
      wx.showToast({
        title: res,
        icon: 'error',
        duration: 2000
      })
    }
  })
})

module.exports = {
  request: request,
  baseURL: baseURL
}

